#!/bin/bash

for template_file in $(find -name "*.template" | grep -v %); do
    target_file=${template_file%.*}
    if [ ! -e $target_file ]; then
        cp $template_file $target_file
        echo now replace $target_file
        while true; do
            result=$(grep "<\w*: \w*>" $target_file | sed 's@.*<slot: \(\w*\).*@\1@')
            if [ "$result" = "" ]; then
                break
            fi
            for key in $result; do
                read -p "the slot $(echo -en "\033[31m")$key$(echo -en "\033[0m") is: " value
                sed -i "s@<slot: $key>@$value@g" $target_file
                break
            done
        done
    fi
done
